﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Data.Common;

namespace MINERP.DAL.Statistics
{
    public class SalesAchievementStatDAL:DALBase
    {
        public static DataSet GetSaleStat(string saleMan, DateTime startTime, DateTime endTime, int LookType)
        {
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("SaleManAchieveMentStat");
            db.AddInParameter(dbCommand, "@saleman", DbType.String, saleMan);
            db.AddInParameter(dbCommand, "@startTime", DbType.DateTime, startTime);
            db.AddInParameter(dbCommand, "@endTime", DbType.DateTime, endTime);
            db.AddInParameter(dbCommand, "@cutNum", DbType.Int32, LookType);
            return db.ExecuteDataSet(dbCommand);
        }

        public static List<string> GetAllSaleMan()
        {

            return DataEntites.Shop.Where(s => s.Salesman != "").Select(p => p.Salesman).Distinct().ToList();
            //Database db = DatabaseFactory.CreateDatabase();
            //string strSql = "select distinct Salesman from shop where Salesman!=' '";
            //DbCommand dbCommand = db.GetSqlStringCommand(strSql);

            //return db.ExecuteDataSet(dbCommand);
        }
    }
}
